package sync.model.auto;

import java.util.Date;
import java.util.Map;

import org.apache.commons.lang.RandomStringUtils;

/**
 * 修改者
 * 
 * @author lili
 * 
 */
public class Modifier implements Runnable {
	private String name;

	public Modifier() {
	}

	public Modifier(String name) {
		this.name = name;
	}

	@Override
	public void run() {
		Map<String, LocalEntity> db = DataBase.localDB;
		while (true) {
			try {
				System.out.println("修改者..." + db.size());
				String i = RandomStringUtils.randomNumeric(2);
				LocalEntity data = db.get(i);
				if (data == null) {
					System.out.println("重新选择修改实体...");
					continue;
				}
				data.setModifyTime(new Date());
				data.setValue(data.getValue() + "-");
				data.setStatus("1");
				System.out.println("卍卍卍修改者[" + this.name + "],修改了编号为："
						+ data.getId() + "的实体的值为：" + data.getValue() + "，修改时间："
						+ data.getModifyTime().getTime());
				Thread.sleep(2000);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	// public static void main(String[] args) {
	// for (int i = 0; i < 10; i++) {
	// System.out.println(RandomStringUtils.randomNumeric(2));
	// }
	// }
}
